package com.jedis;

import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Set;

/**
 * @author gali
 * @date 2022/6/5 10:38
 */
public class JedisDemo {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("192.168.186.128",6379);
        String ping = jedis.ping();
        System.out.println(ping);
        //操作string
        jedis.set("name","gali");
        String name = jedis.get("name");
        System.out.println(name);
        jedis.mset("name","xiaowang","age","18");
        List<String> mget = jedis.mget("name", "age");
        System.out.println(mget);
        //操作list
        jedis.lpush("k1","v1","v2","v3");
        List<String> k1 = jedis.lrange("k1", 0, -1);
        System.out.println(k1);
        //操作set
        jedis.sadd("s1","jack","lucy");
        Set<String> s1 = jedis.smembers("s1");
        System.out.println(s1);
        //操作hash
        jedis.hset("user","name","gali");
        String hget = jedis.hget("user", "name");
        System.out.println(hget);
        //hmset/hmget
        //操作zset
        jedis.zadd("china",100d,"shanghai");
        Set<String> china = jedis.zrange("china", 0, -1);
        System.out.println(china);
        Set<String> keys = jedis.keys("*");
        System.out.println(keys.size());
        jedis.close();
    }
}
